package factory;

import dao.NewsDao;
import dao.impl.NewsDaoImpl;
import dao.impl.NewsDaoMySqlImpl;
import dao.impl.NewsDaoRedisImpl;
import dao.impl.NewsOracleImpl;

/**
 * 具体工厂
 * @version v1.0
 * @Author JieGe
 * @Create 2024-11-30 - 10:26
 */
public class SimpleDaoFactory {

    /**
     * 将dao实现类的对象创建工作进行转移，转移到了当前工厂类
     * instance 实例对象
     */
    public static NewsDao getInstance() { // 里氏替换原则
        return new NewsDaoImpl();
    }

    public static NewsDao getInstance(String key) { // 里氏替换原则
       switch (key) {
           case "mysql":
               return new NewsDaoMySqlImpl();
           case "oracle":
               return new NewsOracleImpl();
           case "redis":
               return new NewsDaoRedisImpl();
       }
        return null;
    }

}
